class MySocket {
  static instance: typeof window.Socket | null = null;

  static getInstance() {
    if (!window.Socket) {
      return null;
    }
    if (!MySocket.instance) {
      MySocket.instance = new window.Socket();
    }
    return MySocket.instance;
  }
}

/**
 * 断开 TCP 连接
 */
export const closeTCPConnect = () => {
  const socket = MySocket.getInstance();
  if (socket) {
    socket.close();
  }
};
export default MySocket;
